

(function( $ ){
    $(function() {
        var locat = (window.location+'').split('/'); 
    	if('pictures'== locat[3]){locat =  locat[0]+'//'+locat[2];}else{locat =  locat[0]+'//'+locat[2]+'/'+locat[3];};
    	$(".docPicker").each(function(i){
    		var target = $(this).attr("id");
	        uploader = WebUploader.create({
	            pick: {
	                id: '#'+target,
	                label: '点击选择文档'
	            },
	            formData: {uid: 123},
	            auto: true,
	            swf: './Uploader.swf',
	            chunked: false,
	            chunkSize: 512 * 1024,
	            server: locat+'/pictures/savedoc.do',
	            accept: {
	                 title: '文档',
	                 extensions: 'doc',
	                 mimeTypes: 'application/msword'
	             },
	            disableGlobalDnd: true,
	            fileNumLimit: 100,
	            fileSizeLimit: 200 * 1024 * 1024,    // 20 M
	            fileSingleSizeLimit: 50 * 1024 * 1024    // 5 M
	        });
	        uploader.on( 'uploadAccept', function( object ,ret  ) {
	        	if(ret){
	        		$("input[name='"+target+"']").val(ret.name);
	        	}
	        });
	        uploader.on( 'uploadSuccess', function( file) {
	        	$("#"+target).find(".webuploader-pick").text("上传成功");
	        });
	        uploader.on( 'uploadProgress', function( file,percentage) {
	        	if(percentage<1){
	        		$("#"+target).find(".webuploader-pick").text(percentage);
	        	}
	        });
	        
	        
    	});
    });
})( jQuery );